'''
Created on May 20, 2010

this module contains functions related to system information
'''

from os import popen

class SystemInfo(object) :


    def __init__(self):
        pass
    
    
    def gethostName(self):
        processCall = popen("uname -n").read()
        return processCall
        
    def getOS(self):
        processCall = popen("uname -o").read()
        return processCall
        
    def getTime_Date(self):
        processCall = popen("date").read()
        return processCall
        
    
    def getKernV_processorArc(self):
        processCall = popen("uname -rp").read()
        return processCall
        
    
    def getSys_uptime(self):
        processCall = popen("uptime |cut -d, -f1").read().strip()
        return processCall
    
    def CPULoadAverages(self):
        processCall = popen("uptime |cut -d, -f3,4,5")
        output = processCall.read().strip().split()
        
        loadAverage = " ".join(output[2:])
        return loadAverage
        
    
    def realMemInfo(self):
        call_process=popen("""echo -n total" "  ; echo -n $(free -m |grep Mem |awk '{ print $2}') ; echo -n " "--- used" " ; free -m |grep Mem |awk '{ print $3}'""").read().strip()
        return call_process
    

def main():
    x = SystemInfo()
    print x.gethostName()
    print x.getOS()
    print x.getTime_Date()
    print x.getKernV_processorArc()
    print x.CPULoadAverages()
    print x.realMemInfo()
    print x.getSys_uptime()

if __name__ == "__main__" :
    main()
    
    